//
//  ReportVIew.m
//  Love trial1。0
//
//  Created by giantumbrella on 15/6/1.
//  Copyright (c) 2015年 赵娟. All rights reserved.
//

#import "ReportVIew.h"
#import "CommonMacro.h"

@interface ReportVIew ()
@property (nonatomic,strong) UIView *bigBgView;
@property (nonatomic,strong) UIView *topBgView;
//@property (nonatomic,strong) UIView *middleBgView;
@property (nonatomic,strong) UIView *buttomBgView;
@property (nonatomic,strong) UIImageView *iconImageView;
@property (nonatomic,strong) UILabel *nameLabel;
@property (nonatomic,strong) UILabel *timeLabel;
@property (nonatomic,strong) UIImageView *goodReportImageView;
@property (nonatomic,strong) UILabel *childOldLabel;
@property (nonatomic,strong) UILabel *reportTextLabel;
@property (nonatomic,strong) UIImage *smallImageView;
@end
@implementation ReportVIew

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if(self)
    {
        [self createView];
    }
    return self;
}

- (void)createView
{
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(10, -38, SCREEN_WIDTH-20, SCREEN_HEIGHT*0.82)];
      [self addSubview:tableView];
//    tableView.backgroundColor = [UIColor greenColor];
    tableView.dataSource = self;
    tableView.delegate = self;
    tableView.showsVerticalScrollIndicator = NO;
  
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{
    
    return 6;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *ID = @"TrailReportCell";
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (cell==nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    
    //0.大背景
    self.bigBgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-20, 280)];
    [cell addSubview:self.bigBgView];
    //    self.bigBgView.backgroundColor = [UIColor redColor];
    
    //1.头部背景
    self.topBgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,self.bigBgView.frame.size.width,self.bigBgView.frame.size.height*0.23)];
    [self.bigBgView addSubview:self.topBgView];
    //    self.topBgView.backgroundColor = [UIColor greenColor];
    
    //1.1头像
    self.iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 8, self.topBgView.frame.size.width*0.18, self.topBgView.frame.size.width*0.18)];
    [self.topBgView addSubview:self.iconImageView];
    self.iconImageView.image = [UIImage imageNamed:@"专题@2x"];
    self.iconImageView.layer.cornerRadius = self.iconImageView.frame.size.width/2;
    self.iconImageView.clipsToBounds = YES;
    self.iconImageView.backgroundColor = [UIColor whiteColor];
    //1.2名字
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.iconImageView.frame.size.width+self.iconImageView.frame.origin.y+3, self.iconImageView.frame.origin.y, self.topBgView.frame.size.width*0.4, self.iconImageView.frame.size.height*0.5)];
    [self.topBgView addSubview:self.nameLabel];
    self.nameLabel.text = @"Linda";
    self.nameLabel.textColor = UIColorWithRGBA(241, 96, 136, 1);
    
    //1.3时间
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.nameLabel.frame.origin.x, self.nameLabel.frame.origin.y+self.nameLabel.frame.size.height, self.nameLabel.frame.size.width, self.nameLabel.frame.size.height)];
    [self.topBgView addSubview:self.timeLabel];
    self.timeLabel.text = @"2小时前";
    self.timeLabel.textColor = UIColorWithRGBA(201, 201, 201, 1);
    
    //1.4优秀报告
    self.goodReportImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.topBgView.frame.size.width*0.744, 10, self.topBgView.frame.size.width*0.25, self.topBgView.frame.size.height*0.35)];
    [self.topBgView addSubview:self.goodReportImageView];
    self.goodReportImageView.image = [UIImage imageNamed:@"优秀报告"];
    
    //1.5孩子岁数
    self.childOldLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.topBgView.frame.size.width*0.59, self.goodReportImageView.frame.size.height+self.goodReportImageView.frame.origin.y, self.topBgView.frame.size.width*0.4, self.goodReportImageView.frame.size.height)];
    [self.topBgView addSubview:self.childOldLabel];
    self.childOldLabel.text = @"孩子两岁半";
    self.childOldLabel.textAlignment = NSTextAlignmentRight;
    self.childOldLabel.font = [UIFont boldSystemFontOfSize:12];
    self.childOldLabel.textColor = UIColorWithRGBA(201, 201, 201, 1);
    //2.正文部分
    self.reportTextLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, self.topBgView.frame.size.height+self.topBgView.frame.origin.y, self.bigBgView.frame.size.width-17, self.bigBgView.frame.size.height*0.5)];
    [self.bigBgView addSubview:self.reportTextLabel];
    self.reportTextLabel.text = @"On Friendship,And a youth said,“Speak to us of Friednship.”Your friend is your needs answered.He is your fild which you sow with love and reap with thandksgiving.And he is your board and your fireside.";
    self.reportTextLabel.numberOfLines = 0;
    [self.reportTextLabel sizeToFit];
    self.reportTextLabel.textColor = UIColorWithRGBA(201, 201, 201, 1);
    self.reportTextLabel.font = [UIFont systemFontOfSize:12];
    //    self.reportTextLabel.backgroundColor = [UIColor blueColor];
    
    //3.底部图片
    self.buttomBgView = [[UIView alloc] initWithFrame:CGRectMake(0, self.reportTextLabel.frame.size.height+self.reportTextLabel.frame.origin.y, SCREEN_WIDTH, self.bigBgView.frame.size.height*0.26)];
    [self.bigBgView addSubview:self.buttomBgView];
    //    self.buttomBgView.backgroundColor = [UIColor greenColor];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return  280;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (self.reportTrailDelegate && [self.reportTrailDelegate respondsToSelector:@selector(reportTrailSideBarRe:didSelectAtIndex:)]) {
        [self.reportTrailDelegate reportTrailSideBarRe:self didSelectAtIndex: indexPath.row ];
    }
}

@end
